﻿
namespace ZquenceStudio3Host.DspPlugins.Synthesizers.Nodesizer.Engine.Modules.GUI
{
    [ModuleDisplay("Parameter")]
    public class Parameter1Module : BaseModule, IGUIModule
    {
        public readonly ModuleOutput Output;

        public readonly ModuleParameter ParameterValue;

        private double Value { get; set; }

        public Parameter1Module(ModuleManager manager)
            : base(manager)
        {
            AddOutput(Output = new ModuleOutput("Output", IOType.AudioOrWaveform, this));

            ParameterValue = new ModuleParameter(this);
            ParameterValue.Label = "Value";
            ParameterValue.MinValue = 0;
            ParameterValue.MaxValue = 1;
            ParameterValue.DirectGet += delegate { return Value; };
            ParameterValue.DirectSet += delegate (double value) { Value = value; };
            AddParameter(ParameterValue);
        }

        public override void Process()
        {
            if (Output.IsConnected)
            {
                for (int i = Output.AudioBuffer.Length - 1; i >= 0; i--)
                {
                    Output.AudioBuffer[i] = Value;
                }
            }
        }
    }
}
